#ifndef NATIONALINSTRUMENTS_H
#define NATIONALINSTRUMENTS_H

#include <NIDAQmx.h>
#include <stdio.h>
#include <string.h>
#include <QString>
#include <QDebug>
#include <QObject>

class NationalInstruments// : public QObject
{
    //Q_OBJECT

public:
    NationalInstruments(QObject * parent = 0);
    ~NationalInstruments();

    void Initialize();

    //Turn on and off the freq_out spare clock/counter on NI boards
    void InitializeFrequencyOutput();
    void ShutdownFrequencyOutput();

    //Flip the firgelli lines on the fly, actuating the firgelli
    void ChangeFirgelliState(int state, int id);

    //Outputs a digital pulse on the fly, say triggering a ScanImage/Matrox
    //acquisition
    void OutputDigitalPulse(const char* cDevicePortLine, int state);

    //Sets digital line
    void SetDigitalLine(const char* cDevicePortLine, uInt8 state);


    void SetResonantScannerSelectBits(int sel1, int sel2, int shutoff);
    void SetResonantScannerAmplitude(double scanfraction);
    void SetResonantScannerStandby(bool standby);
    void StartResonantScanning();
    void StopResonantScanning();
    void OpenShutter(int id);
    void CloseShutter(int id);
    void ResetHSync();

    bool bResonantScanning;

    bool bFastBlank;
    bool bSlowBlank;
    double dLaserPower;

    int nLinesPerFrame;
    double dFastFreq;
    int nEdgeWidth;

    double dFastBlankDelay;
    double dFastBlankWidth;
    double dSlowBlankDelay;
    double dSlowBlankWidth;

    double dYScanAmplitudeVolts;
    double dYScanOffsetVolts;
    double dYScanFraction;
    double dYRampDutyCycle;

    //misc parameters
    double dXResonanceFrequency; //approx (bounds?)
    double dXScanAmplitudeVolts;
    double dXScanFraction;

    int     nExtraZoom;
    int     nPulseDelay;
    int     nPulseDelay1x,
            nPulseDelay2x,
    nPulseDelay4x,
    nPulseDelay8x,
    nPulseDelay16x,
    nPulseDelay32x,
    nPulseDelay64x;

    double  dFastBlankDelay1x,
    dFastBlankDelay2x,
    dFastBlankDelay4x,
    dFastBlankDelay8x,
    dFastBlankDelay16x,
    dFastBlankDelay32x;

    double  dFastFreq1x,
    dFastFreq2x,
    dFastFreq4x,
    dFastFreq8x,
    dFastFreq16x,
    dFastFreq32x;

    int     nActuatorPinoutVersion;

    void Shutdown();

    TaskHandle tFreqOutput;
    TaskHandle  tFrameSampleClock,
    tVSyncDivider,
    tCRSSyncCounter,
    tNI_AnalogOut,
    tPockelsCell,
    tCRSDigital;

public slots:

private slots:
};

#endif // NATIONALINSTRUMENTS_H
